<template>
	<view class="cardListBox">
		<view v-if="cardsList.length > 0">
			<view class="tip1">
				单笔订单可使用
				<text>1张</text>
				卡
			</view>
			<view class="demo">
				<view class="cardsList" v-for="(item, index) in cardsList" v-if="item.type!=1" :key="index" 
				@tap="parseEventDynamicCode($event, item.unavailabilityReason!='' ? '' : 'checkCard')" :data-id="item.id">
					<view class="cardsItem" :style="{ 'backgroundImage': 'url(' + `${item.notApplyStatus > 1?card3_icon:card2_icon}` + ')' }">
						<view class="top">
							<view class="left">
								<view style="width: 300rpx;height: 42rpx;font-size: 34rpx;color: #4b2312;">
									{{item.type == 2? "折扣卡": item.type == 3? "金额卡": "次数卡"}}
								</view>
								<view><span v-if='item.availableNum'>{{ item.availableNum }}次 |</span>
									{{ item.applyStationType == 1?'所有站点':item.applyStationType==2?'指定站点':'指定条件' }}
								</view>
							</view>
							<!-- <view class="cardAmount">满￥{{item.cardAmount}}可用</view> -->
							<view class="right" v-if="item.type!=2">
								<view>{{ item.availableDegrees }}</view>
								<view>/{{ item.amount }}{{item.type == 4?'次':'' }}</view>
							</view>
							<view class="right" v-if="item.type==2">
								<view>{{ item.amount}}</view>
								<view>折</view>
							</view>
						</view>
						<view>
							有效期：
							<text>{{ item.fixedStartTime }}</text>至<text>{{ item.fixedEndTime }}</text>
						</view>
						<view class=''>
							<image v-if='index==tabIndex' :src='base_url+"/group1/image/对号6255631624553423637.png"'
								style='width: 20rpx;height: 20rpx;'></image>
						</view>
					</view>
					<view class="statusDesc" v-if="item.notApplyStatus==2">
					    <image src="http://oos-cn.ctyunapi.cn/front-end/static/marketingImg/orderSub/images/tip1.png" class="img"></image>
					    <view class="desc">
					        <text>不可用原因：</text>
					        {{ item.notApplyCause }}
					    </view>
					</view>
				</view>
				<view class="fotBtn">
					<view class="tip2">
						已选
						<text class="txt1">{{ num }}张</text>
						<block v-for="(item, index) in cardsList" :key="index">
				            <text class="txt3" v-if="item.status == 0">{{ item.type == 2 ? '可折扣' + item.couponAmount+'折' : '' }}</text>
						</block>
					</view>
					<view class="btn" @tap="getCardLists">确定</view>
				</view>
			</view>
		</view>
		<view v-else>
			<Upgrading text="暂无数据"></Upgrading>
		</view>
	</view>
</template>

<script>
	import {
		powerOtherCardSelectionList
	} from '@/api/marketing/coupon'
	var app = getApp();
	export default {
		data() {
			return {
				cardsList: [],
				card2_icon: `${app.globalData.imgUrl}/group1/operateSchemeImage/image/card2_icon.png`,
				card3_icon:  `${app.globalData.imgUrl}/group1/image/bg3399643139773774895.png`,
				base_url: app.globalData.imgUrl,
				tabIndex: "",
				num: 0,
			};
		},
		onLoad(options) {
			if (options.busBalance) {
				this.setData({
					busBalance: options.busBalance
				});
			}
			if (options.powerBalance) {
				this.setData({
					powerBalance: options.powerBalance
				});
			}
			if (options.serviceBalance) {
				this.setData({
					serviceBalance: options.serviceBalance
				});
			}
			if (options.stationId) {
				this.setData({
					stationId: options.stationId
				});
			}
			if (options.billId) {
				this.setData({
					billId: options.billId
				});
			}
			if (options.cardIdStr) {
				this.setData({
					cIdStr: options.cardIdStr
				});
			}
			if (options.serviceFee) {
				this.setData({
					serviceFee: parseFloat(options.serviceFee)
				});
			}
			this.getPowerCardSelectionLists();
		},
		methods: {
			getPowerCardSelectionLists() {
				let settlementCouponVo = {
					busBalance: this.busBalance,
					powerBalance: this.powerBalance,
					serviceBalance: this.serviceBalance,
					stationId: this.stationId,
				}
				powerOtherCardSelectionList(settlementCouponVo).then(res => {
					if (res.code == 200) {
						this.cardsList = res.data || [];
					}
				})
			},
			checkCard(){
				
			},
			getCardLists() {
				
			},
		},
	};
</script>

<style lang="less" scoped>
	@import "../../../../commin/commin.less";

	page {
		background-color: #f5f7fa;
		padding-bottom: 120rpx;
	}

	.cardAmount {
		width: 400rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		font-size: 28rpx;
		justify-content: center;
	}

	.cardListBox {
		width: 100%;
		min-height: 100vh;
		background: #f5f7fa;
	}

	.demo {
		width: 94%;
		margin: 0rpx auto;
		padding-bottom: 240rpx;
	}
	.cardsList{
		width: 100%;
		height:100%;
	}
	.cardsItem {
		width: 100%;
		margin: 20rpx auto;
		background-size: 110% 130%;
		background-repeat: no-repeat;
		background-position: center;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: flex-start;
		padding: 40rpx;
		box-sizing: border-box;
		overflow: hidden;
		border-radius: 20rpx;
		position: relative;
		.img {
		    width: 100%;
		    height: 100%;
		}

		.top {
			width: 100%;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: flex-start;
			color: #4b2312;

			.left {
				>view:nth-of-type(1) {
					font-size: 34rpx;
					font-weight: 400;
					color: #4b2312;
				}

				>view:nth-of-type(2) {
					margin-top: 20rpx;
					font-size: 22rpx;
					width: 300rpx;
					height: 42rpx;
					text-align: left;
					line-height: 42rpx;
					color: rgba(94, 50, 30, 0.8);
					border-radius: 21rpx;
				}
			}

			.right {
				width: 260rpx;
				height: 80rpx;
				display: flex;
				flex-direction: row;
				justify-content: flex-end;
				align-items: flex-end;

				>view {
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					align-items: flex-end;
				}

				>view:nth-of-type(1) {
					height: 80rpx;
					font-size: 48rpx;
					font-weight: bold;
				}

				>view:nth-of-type(2) {
					height: 80rpx;
					font-size: 32rpx;
				}
			}
		}

		>view:nth-of-type(2) {
			width: 100%;
			margin-top: 16rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #5e321e;
		}

		>view:nth-of-type(3) {
			width: 26rpx;
			height: 26rpx;
			border-radius: 50%;
			border: 2rpx solid #fff;
			position: absolute;
			right: 32rpx;
			bottom: 32rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}

	.fotBtn {
		position: fixed;
		bottom: 0;
		background-color: #f5f7fa;
		height: 137rpx;
		padding: 20rpx 35rpx 53rpx 35rpx;
	}

	.fotBtn .tip2 {
		text-align: center;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #303133;
	}

	.fotBtn .tip2 .txt1 {
		color: #1487fa;
	}

	.fotBtn .tip2 .txt2 {
		font-size: 30rpx;
		font-family: DIN-Bold;
		font-weight: Bold;
		color: orange;
	}

	.fotBtn .tip2 txt3 {
		color: #606266;
	}

	.fotBtn .btn {
		width: 680rpx;
		line-height: 88rpx;
		margin-top: 24rpx;
		text-align: center;
		background: linear-gradient(105deg, #2b99ff, #1b8cf5);
		box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0, 110, 212, 0.3);
		border-radius: 44rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #fff;
	}

	.tip1 {
		text-align: center;
		font-size: 28rpx;
		padding: 39rpx 0 36rpx 0;
		font-family: PingFang SC;
		font-weight: 500;
		color: #606266;
	}

	.tip1 text {
		color: #fc724c;
		font-size: 30rpx;
	}
	.statusDesc {
	    display: flex;
	    margin-bottom: 16rpx;
	}
	.statusDesc .img {
	    width: 32rpx;
	    height: 32rpx;
	    margin: 0 10rpx 0 12rpx;
	}
	.statusDesc .desc {
	    font-size: 26rpx;
	    font-family: PingFang SC;
	    font-weight: 500;
	    color: #303133;
	}
	.statusDesc .desc text {
	    color: #fc724c;
	}
</style>